<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet" href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
.box-header {
    color: #444;
    display: block;
    padding: 10px;
    position: relative;
    height: 40px;
}
</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div class='full-center-content-scroll-noheader'>
			<div class="nav-tabs-custom">
				<div class="tab-content no-padding">
					<div class="chart tab-pane active" style="position: relative; height: 805px;">
						<div class="row">
							<div class="col-md-3 full-content"  style=" height: 800px;">
								<div class="box box-primary">
									<div class="box-header with-border" id="searchInput">
										<div class="box-tools pull-left" style="top: 0;left:0">
											<h:form id="form1">
												<p:growl id="msg" showDetail="true" />
												<p:toolbar>
													<f:facet name="left">
														<p:commandButton value="新建" icon="ui-icon-plus" id="createBtn"
															rendered="#{s:hasPermission(session,'jcsj_sjwh_dwgldwwh_xj')}"
															actionListener="#{managementUnitController.preCreate}"
															disabled="#{managementUnitController.currentNode == null}"
															oncomplete="PF('createUnit').show()" update=":dialogForm:createUnit :dialogForm:unitName :dialogForm:unitType" />
														<p:commandButton value="编辑" icon="ui-icon-pencil" id="edit"
															rendered="#{s:hasPermission(session,'jcsj_sjwh_dwgldwwh_bj')}"
															disabled="#{managementUnitController.currentNode == null}"
															actionListener="#{managementUnitController.preEdit}"
															oncomplete="PF('createUnit').show()" update=":dialogForm:createUnit :dialogForm:orderd" />
														<p:commandButton value="删除" icon="ui-icon-trash" id="delet"
															rendered="#{s:hasPermission(session,'jcsj_sjwh_dwgldwwh_sc')}"
															disabled="#{managementUnitController.currentNode == null}"
															actionListener="#{managementUnitController.delete}"
															update="msg :form2:tree form1">
															<p:confirm header="提示" message="该单位下的所有子单位会被同时删除，确定删除该记录吗?" icon="ui-icon-alert" />
														</p:commandButton>
														<p:commandButton id="newStatBtn" value="上传文件" icon="ui-icon-arrowthick-1-n"
															rendered="#{s:hasPermission(session,'jcsj_sjwh_dwgldwwh_scwj')}"
															actionListener="#{managementUnitController.openUploadDialog}">
															<p:confirm header="提示" message="必须保证同一父级单位的子单位在文档中的位置是连续的！" icon="ui-icon-alert" />
															<p:ajax event="dialogReturn" update="form1:msg"
																listener="#{managementUnitController.onSelectorChosen}" />
														</p:commandButton>
													</f:facet>
												</p:toolbar>
											</h:form>
										</div>
									</div>
									<div class="box-body  full-content-scroll">
										<h:form id="form2">
											<p:tree id="tree" style="border:0" value="#{managementUnitController.root}"
												selectionMode="single" var="unit" dynamic="true" animate="true">
												<p:ajax event="select" listener="#{managementUnitController.onNodeSelect}" update=":form1:createBtn :form1:edit :form1:delet"/>
												<p:ajax event="expand" update="tree" listener="#{managementUnitController.onNodeExpand}" />
												<p:treeNode>
													<h:outputText value="#{unit}" />
												</p:treeNode>
											</p:tree>
										</h:form>
										<h:form id="dialogForm">
											<p:dialog widgetVar="createUnit" header="单位名称" modal="true" id="createUnit"
												width="300" height="160">
												<p:toolbar>
													<f:facet name="left">
														<p:commandButton value="保存" icon="ui-icon-disk"
															actionListener="#{managementUnitController.saveUnit}"
															oncomplete="PF('createUnit').hide()" update=":form2:tree :form1:msg :form1:createBtn :form1:edit :form1:delet" />
														<p:commandButton value="取消" icon="ui-icon-cancel"
															oncomplete="PF('createUnit').hide()" />
													</f:facet>
												</p:toolbar>
												<p:panelGrid columns="2">
													<p:outputLabel value="名称" />
													<p:inputText value="#{managementUnitController.unit.name}" id="unitName"/>
													<p:outputLabel value="类型" />
													<p:inputText value="#{managementUnitController.unitType}" id="unitType" readonly="true"/>
													<p:outputLabel value="序号" />
													<p:inputText id="orderd" value="#{managementUnitController.unit.ordered}" rendered="#{managementUnitController.unit.id!=null}"/>
													<h:outputText  value="#{managementUnitController.unit.ordered}" rendered="#{managementUnitController.unit.id==null}"/>
												</p:panelGrid>
											</p:dialog>
										</h:form>
									</div>
									<div class="box-footer"></div>
								</div>
							</div>
							<div class="col-md-9 full-content" style="padding-left: 0px; height: 800px;">
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</ui:define>
	<ui:define name="contentend">
	</ui:define>
</ui:composition>
